$(function () {
    $('section.u-c-menu-list a').each(function(index, value) {
        value = $(value);
        var urls =location.href;
        if(urls.indexOf('/web/uc/order/orderInfo')!=-1){
            if (value.attr('href').indexOf("/web/uc/order/list")!=-1) {
                value.parent().addClass('active').siblings().removeClass('active');
            }
        }
    });

    $("body").on('click','#printPageBtn',function () {
        printThis();
    }).on('click','.sign-book',function () {
        var _this = $(this);
        var orderId = _this.data('id');
        icModale(2, '提示', '确认要签收订单？', null, null,function (index) {
            $.ajax({
                url:baseloaction+'/web/uc/order/signOrder',
                type:'post',
                dataType:'json',
                data:{
                    'orderId':orderId
                },
                success:function (result) {
                    if(result.success==true){
                        _this.remove();
                        layer.close(index);
                    }else{
                        icModale(0,'',result.message);
                    }
                },
                error:function () {
                    icModale(0,'','系统错误，订单签收失败');
                }
            });
        });
    });

    //区域打印订单
    function printThis() {
        var bdhtml=window.document.body.innerHTML;
        var sprnstr="<!--startprint-->";
        var eprnstr="<!--endprint-->";
        var prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
        var prnhtmlBox=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
        window.document.body.innerHTML=prnhtmlBox;
        //移除页面中的a标签的href否则会打印出来
        $('a').removeAttr("href");
        window.print();
        //还原原来的内容
        setTimeout(function(){
            window.document.body.innerHTML=bdhtml;
        },100)

    }
});
